// 用户API
const install = (Vue, vm) => {
  // 登录
  let phoneLogin = (data) => vm.$zx.post('/auth/login', data);
  // 注销用户
  let logoutLogin = (data) => vm.$zx.post('/api/myInfo/logOff', data);
  // 获取消息
  let getMessages = ({ page, status }) =>
    vm.$zx.get(
      `/messagePush/getMessageByUid?pageNo=${page}&pageSize=10` +
        (status !== null ? `&status=${status}` : '')
    );
  // 修改消息状态
  let updateMessageStatus = (id, status) =>
    vm.$zx.get(`/messagePush/updateStatus/${id}/${status}`);
  // 获取用户信息
  let getUserInfo = () => vm.$zx.post('/user/userInfo');
  // 修改头像
  let updateAvatar = (file) => vm.$zx.post('/user/update/avatar', file);
  // 修改密码
  let updatePassword = (data) => vm.$zx.post('/user/update/password', data);
  // 获取短信验证码
  let sendVerifyCodeSms = (data) =>
    vm.$zx.post('/common/sendVerifyCodeSms', data);
  // 修改密码
  let forgetPassword = (data) => vm.$zx.post('/user/forgetPassword', data);
  // 首页数据
  let getHomeData = () => vm.$zx.post('/api/myInfo/homeData');
  let getAllChannelLists = () => vm.$zx.get('/api/acqChannel/listAllChannel');
  let switchingChannel = (channelNo) =>
    vm.$zx.post('/api/myInfo/switchingChannel', channelNo);
  // 业绩
  let getBenefitDetailData = () =>
    vm.$zx.post('/api/dataStat/performanceOverview');
  let accountStatistics = () => vm.$zx.post('/api/myInfo/accountStatistics');
  let merchantCountList = (data) =>
    vm.$zx.post(`/api/activityCount/merchantCountList`, data);
  let incomeStat = () => vm.$zx.post(`/api/dataStat/incomeStat`);
  let merchantInfoQuery = (pageNo, pageSize, data) =>
    vm.$zx.post(`/api/merchantInfo/queryPage/${pageNo}/${pageSize}`, data);
  let agentList = (pageNo, pageSize, data) =>
    vm.$zx.post(`/api/agent/list/${pageNo}/${pageSize}`, data);
  let agentTopData = (pageNo, pageSize, data) =>
    vm.$zx.post(`/api/dataStat/agentTopData/${pageNo}/${pageSize}`, data);
  let listMyAccount = () => vm.$zx.post(`/api/myInfo/listMyAccount`);
  let querySetter = () => vm.$zx.get(`/api/myInfo/querySetter`);
  let updateSetter = (data) => vm.$zx.post(`/api/myInfo/updateSetter`, data);
  let myInfoUpdatePassword = (data) =>
    vm.$zx.post(`/api/myInfo/updatePassword`, data);
  let saveAgent = (data) => vm.$zx.post(`/api/agent/saveAgent`, data);
  let agentAllAchievement = (agentNo) =>
    vm.$zx.post(`/api/agent/allAchievement/${agentNo}`);
  let agentAllAchievement2 = (agentNo, data) =>
    vm.$zx.post(`/api/agent/achievement2/${agentNo}`, data);
  // 获取代理商详情
  let getAgentDetail = (agentNo) => vm.$zx.get(`/api/agent/detail/${agentNo}`);
  let queryMyInfo = (agentNo) => vm.$zx.get(`/api/myInfo/queryMyInfo`);
  vm.$zx.user_api = {
    phoneLogin,
    getMessages,
    updateMessageStatus,
    getUserInfo,
    updateAvatar,
    updatePassword,
    sendVerifyCodeSms,
    forgetPassword,
    getHomeData,
    getAllChannelLists,
    switchingChannel,
    getBenefitDetailData,
    accountStatistics,
    merchantCountList,
    incomeStat,
    merchantInfoQuery,
    agentList,
    agentTopData,
    listMyAccount,
    querySetter,
    updateSetter,
    myInfoUpdatePassword,
    saveAgent,
    agentAllAchievement,
    agentAllAchievement2,
    getAgentDetail,
    queryMyInfo,
    logoutLogin,
  };
};

export default {
  install,
};
